#! /bin/bash

# Author : Vincent
# Warning, this piece of code comes with no warranty

########
# Goal of this script : to install JOnas. It is a subpart of
#   deploy_ecom.sh which should be included in the same directory.
########

#TODO: que mettre dans jonas base ?

# Download
# if not file
if [ ! -f jonas-full-5.2.3-bin.tar.gz ] ; then
    wget -nv ${FILE_REPO}/bin/jonas-full-5.2.3-bin.tar.gz && echo '' && echo "JOnas was downloaded successfully."
else
    echo "The JOnas archive is already downloaded."
fi

# Untar
# if not directory
if [ ! -d jonas-full-5.2.3/ ] ; then
    tar xf jonas-full-5.2.3-bin.tar.gz
else
    echo "JOnas is already unpacked."
fi

# Set environment variables
export JONAS_ROOT=$(pwd)/jonas-full-5.2.3/

if [ ! -d ~/.jonas_base ] ; then
    mkdir ~/.jonas_base
fi

export JONAS_BASE="$(pwd)/.jonas_base"


export PATH=$PATH:${JONAS_BASE}
export PATH=$PATH:${JONAS_ROOT}/bin

echo "============"
echo "=== newjb"
echo "============"

newjb
# j'ai essayé sans succès :
# while read line; do
#     answer=$(echo "$line" | prog)
# done < file

# dommage ça a l'air bien 
cd ..
